package com.nbsaas.boot.front.site;

import com.nbsaas.boot.rest.annotations.ViewOperator;
import com.nbsaas.boot.rest.response.ListResponse;
import com.nbsaas.boot.rest.response.PageResponse;
import com.nbsaas.boot.rest.response.ResponseObject;
import com.nbsaas.boot.site.api.apis.DynamicPageApi;
import com.nbsaas.boot.site.api.domain.request.DynamicPageRequest;
import com.nbsaas.boot.site.api.domain.request.DynamicPageSearch;
import com.nbsaas.boot.site.api.domain.response.DynamicPageResponse;
import com.nbsaas.boot.site.api.domain.simple.DynamicPageSimple;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 控制器
 */
@RestController
@RequestMapping("/front/dynamicPage")
public class DynamicPageAction {


    @Resource
    private DynamicPageApi dynamicPageApi;

    /**
     * 搜索数据
     *
     * @param request
     * @return
     */
    @PostMapping("/search")
    public PageResponse<DynamicPageSimple> search(@RequestBody DynamicPageSearch request) {
        return dynamicPageApi.search(request);
    }

    /**
     * 列表数据
     *
     * @param request
     * @return
     */
    @PostMapping("/list")
    public ListResponse<DynamicPageSimple> list(@RequestBody DynamicPageSearch request) {
        return dynamicPageApi.list(request);
    }


    /**
     * 查看数据
     *
     * @param request
     * @return
     */
    @PostMapping("/view")
    public ResponseObject<DynamicPageResponse> view(@RequestBody @Validated(ViewOperator.class) DynamicPageRequest request) {
        return dynamicPageApi.view(request);
    }
}